package com.my.event.model;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 事件触发---可以参考blade的日志系统 的日志事件触发
 * @author timo 2021/2/18
 */
@Controller
@RequestMapping("/test2")
public class TestController {

    @Resource
    private ApplicationContext applicationContext;


    @ResponseBody
    @RequestMapping("/testListener")
    public String testListener(){
        applicationContext.publishEvent(new AddDataEvent(this,TestController.class,"test"));
        return "success";
    }
}
